package com.tbit.uqbike.object.pojo.dto;

import com.tbit.uqbike.constant.SysConstant;
import com.tbit.uqbike.object.business.Point;
import com.tbit.uqbike.service.base.CalibrateService;
import lombok.Data;

import javax.validation.constraints.NotNull;

/**
 * 显示还车点
 *
 * @Author LHX
 * @ClassName GetReturnBikePointDTO
 * @Description
 * @date 2023/5/26 10:36
 * @Version 1.0
 */
@Data
public class GetReturnBikePointDTO {

    /**
     * 品牌id
     */
    @NotNull
    private Integer brandId;

    /**
     * 区域id
     */
    @NotNull
    private Integer accountId;

    /**
     * 距离(单位：米)
     */
    private Integer distance;

    /**
     * 经度
     */
    private Double lon;
    /**
     * 维度
     */
    private Double lat;

    private Double lonMax;
    private Double latMax;
    private Double lonMin;
    private Double latMin;


    /**
     * 是否显示 (0:站内还车点 1:站外还车点)
     */
    private Integer isDisplayType;

    /**
     * 还车类型(0:实际还车点 1:申诉还车点 2:意向还车点)
     */
    private Integer returnType;

    /**
     * 上报类型(0:终端 1:手机)
     */
    private Integer reportType;

    /**
     * 显示时间(0:最近一周 1:最近半月 2:最近一个月)
     */
    private Integer returnTime;

    public void compute(CalibrateService calibrateService) {
        if (lat == null || lon == null || distance == null) {
            return;
        }
        Point point = calibrateService.commonCalibrate(new Point(lon, lat), SysConstant.GOOGLE, SysConstant.ORIGINAL);
        Double area = 0.00001D * distance;
        lonMax = point.getX() + area;
        lonMin = point.getX() - area;
        latMax = point.getY() + area;
        latMin = point.getY() - area;
    }
}
